cmake_minimum_required(VERSION 3.16)

project(Dragon LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt6 REQUIRED COMPONENTS OpenGL OpenGLWidgets)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/Library)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/Library)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/Runtime)

include_directories(${SOLUTION_DIR}/Softwarer/QHutu)
include_directories(${SOLUTION_DIR}/Softwarer/Debugging)

set(PROJECT_HEADERS
  dragon_global.h
  Light.h
  Camera.h
  Screen.h
  Texture.h
  Uniform.h
  Material.h
  Geometry.h
  Attribute.h
)

set(PROJECT_SOURCES
  Light.cpp
  Camera.cpp
  Screen.cpp
  Texture.cpp
  Uniform.cpp
  Material.cpp
  Geometry.cpp
  Attribute.cpp
)

install(FILES ${PROJECT_HEADERS} DESTINATION Includes/${PROJECT_NAME}/)

add_library(${PROJECT_NAME} SHARED ${PROJECT_HEADERS} ${PROJECT_SOURCES})

link_directories(${SOLUTION_DIR}/Library)

target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::OpenGL Qt6::OpenGLWidgets)
target_link_libraries(${PROJECT_NAME} PRIVATE QHutu)
target_link_libraries(${PROJECT_NAME} PRIVATE Debugging)

target_compile_definitions(${PROJECT_NAME} PRIVATE DRAGON_LIBRARY)
